home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / S / CUCDprefs.rexx < prev    next >
OS/2 REXX Batch file  |  1997-11-04  |  6KB  |  159 lines

  1. /* Load, save CUCD prefs for CUCDprefs.mrx */
  2.  
  3. VerStr = '$VER: CUCDprefs 1.1 (4.11.97) Neil Bothwick'
  4. VerStr = subword(VerStr,2)
  5.  
  6. /* 1.1 - added option for DigiBooster modules */
  7.  
  8. options results
  9. arg action
  10.  
  11. PrefsFile = 'IDer.prefs'
  12. DefPrefs  = 'CUCD:S/IDer.prefs'
  13. types = 'IFF GIF JPG ANM MPG SVX WAV S3M XMM MED DBM MOD MP3 MID AGD HTM LHA DEF'
  14. address CDPREFS
  15.  
  16. /* ;;; Select action */
  17. select
  18.     when action = 'SAVE' then do
  19.         call SavePrefs()
  20.         'quit'
  21.         end
  22.     when action = 'USE'  then do
  23.         call UsePrefs()
  24.         'quit'
  25.         end
  26.     when action = 'READ' then do
  27.         Prefs = 'ENV:'PrefsFile
  28.         call LoadPrefs()
  29.         end
  30.     when action = 'LOAD' then do
  31.         Prefs = 'ENVARC:'PrefsFile
  32.         call LoadPrefs()
  33.         end
  34.     when action = 'RESTORE' then do
  35.         Prefs = DefPrefs
  36.         call LoadPrefs()
  37.         end
  38.     when action = 'ABOUT' then call AboutPrefs()
  39.     otherwise nop
  40.     end
  41. ;;;
  42. exit
  43.  
  44. /* ;;; Load prefs */
  45. LoadPrefs:
  46.     if ~exists(Prefs) then Prefs = DefPrefs
  47.  
  48.     if ~open(prefs,Prefs,'R') then do
  49.     request ID FAIL title '"CU Amiga CD preferences"' gadgets 'OK' '"Failed to read preferences file"'
  50.         quit
  51.         exit
  52.         end
  53.  
  54.     PrefsLine = readln(prefs)
  55.     setvar CfgVersion PrefsLine
  56.  
  57.     do until eof(prefs)
  58.         PrefsLine = readln(prefs)
  59.         if PrefsLine = '' then iterate
  60.         if pos(left(PrefsLine,1),';#') > 0 then iterate
  61.         PrefsLine = substr(PrefsLine,pos('CLASS=',upper(PrefsLine)) + 6)
  62.         if left(PrefsLine,1) = '"' then parse var Prefsline '"' Class '"' PrefsLine /*Class = substr(PrefsLine,2,pos('"',PrefsLine,2) - 2)*/
  63.         else parse var PrefsLine Class PrefsLine
  64.         PrefsLine = strip(PrefsLine)
  65.         parse var PrefsLine Defn 'ACTION=' Action
  66.         interpret Class'.cmd="'word(Action,1)'"'
  67.         interpret Class'.arg="'subword(Action,2)'"'
  68.         end
  69.  
  70.     popasl ID IFF0 CONTENT IFF_Picture.cmd
  71.     popasl ID GIF0 CONTENT GIF_Picture.cmd
  72.     popasl ID JPG0 CONTENT JPEG_Picture.cmd
  73.     popasl ID ANM0 CONTENT ANIM.cmd
  74.     popasl ID MPG0 CONTENT MPEG_Video.cmd
  75.     string ID IFF1 CONTENT IFF_Picture.arg
  76.     string ID GIF1 CONTENT GIF_Picture.arg
  77.     string ID JPG1 CONTENT JPEG_Picture.arg
  78.     string ID ANM1 CONTENT ANIM.arg
  79.     string ID MPG1 CONTENT MPEG_Video.arg
  80.     popasl ID SVX0 CONTENT IFF_Sample.cmd
  81.     popasl ID WAV0 CONTENT WAV_Sample.cmd
  82.     popasl ID S3M0 CONTENT S3M_Module.cmd
  83.     popasl ID XMM0 CONTENT XM_Module.cmd
  84.     popasl ID MED0 CONTENT MED_Module.cmd
  85.     popasl ID DBM0 CONTENT DBM_Module.cmd
  86.     popasl ID MOD0 CONTENT Module.cmd
  87.     popasl ID MP30 CONTENT MPEG_Audio.cmd
  88.     popasl ID MID0 CONTENT MIDI.cmd
  89.     string ID SVX1 CONTENT IFF_Sample.arg
  90.     string ID WAV1 CONTENT WAV_Sample.arg
  91.     string ID S3M1 CONTENT S3M_Module.arg
  92.     string ID XMM1 CONTENT XM_Module.arg
  93.     string ID MED1 CONTENT MED_Module.arg
  94.     string ID DBM1 CONTENT DBM_Module.arg
  95.     string ID MOD1 CONTENT Module.arg
  96.     string ID MP31 CONTENT MPEG_Audio.arg
  97.     string ID MID1 CONTENT MIDI.arg
  98.     popasl ID AGD0 CONTENT Guide.cmd
  99.     popasl ID HTM0 CONTENT HTML.cmd
  100.     popasl ID LHA0 CONTENT LhA_Archive.cmd
  101.     popasl ID DEF0 CONTENT Default.cmd
  102.     string ID AGD1 CONTENT Guide.arg
  103.     string ID HTM1 CONTENT HTML.arg
  104.     string ID LHA1 CONTENT LhA_Archive.arg
  105.     string ID DEF1 CONTENT Default.arg
  106.  
  107.     return
  108. ;;;
  109. /* ;;; Use prefs */
  110. UsePrefs:
  111.     do i = 1 to words(types)
  112.         type = word(types,i)
  113.         interpret 'popasl ID' type'0'
  114.         interpret type '= result'
  115.         interpret 'string ID' type'1'
  116.         interpret type '= strip('type' result)'
  117.         end
  118.  
  119.     if ~open(prefs,'ENV:'PrefsFile,'W') then request ID FAIL title '"CU Amiga CD preferences"' gadgets 'OK' '"Failed to save preferences"'
  120.     else do
  121.         call writeln(prefs,'# IDer Prefs file - created by CUCD prefs'||'0a'x)
  122.         call writeln(prefs,'# IDer  --  © 1995 Eclipse Software'||'0a'x)
  123.  
  124.         call writeln(prefs,'CLASS=IFF_Picture OFFSET=0,"FORM????ILBM"  ACTION='IFF)
  125.         call writeln(prefs,'CLASS=GIF_Picture SUFFIX=.GIF  OFFSET=0,"GIF87a"  ACTION='GIF)
  126.         call writeln(prefs,'CLASS=JPEG_Picture OFFSET=6,4A464946   ACTION='JPG)
  127.         call writeln(prefs,'CLASS=ANIM SUFFIX=.ANIM  OFFSET=0,"FORM????ANIM"  ACTION='ANM)
  128.         call writeln(prefs,'CLASS=MPEG_Video SUFFIX=.MPG  ACTION='MPG)
  129.         call writeln(prefs,'CLASS=IFF_Sample OFFSET=0,"FORM????8SVX"  ACTION='SVX)
  130.         call writeln(prefs,'CLASS=WAV_Sample OFFSET=0,"RIFF????WAVE"  ACTION='WAV)
  131.         call writeln(prefs,'CLASS=S3M_Module SUFFIX=.S3M  NAME=S3M.#?  OFFSET=44,"SCRM"  FLAGS=T  ACTION='S3M)
  132.         call writeln(prefs,'CLASS=XM_Module SUFFIX=.XM OFFSET=0,"Extended Module:" FLAGS=I ACTION='XMM)
  133.         call writeln(prefs,'CLASS=MED_Module SUFFIX=.MED  NAME=MED.#?  OFFSET=0,"MMD?"  ACTION='MED)
  134.         call writeln(prefs,'CLASS=DBM_Module SUFFIX=.DBM  OFFSET=0,"DBM0"  ACTION='DBM)
  135.         call writeln(prefs,'CLASS=Module SUFFIX=.MOD  NAME=MOD.#?  OFFSET=1080,"M.K."  FLAGS=T  ACTION='MOD)
  136.         call writeln(prefs,'CLASS=MPEG_Audio NAME=(#?.MP3|#?.MP2) FLAGS=I ACTION='MP3)
  137.         call writeln(prefs,'CLASS=MIDI SUFFIX=.MID OFFSET=0,"MThd" ACTION='MID)
  138.         call writeln(prefs,'CLASS=Guide SUFFIX=.GUIDE  OFFSET=0,"@database"  FLAGS=I  ACTION='AGD)
  139.         call writeln(prefs,'CLASS=HTML NAME=(#?.html|#?.htm) FLAGS=I  ACTION='HTM)
  140.         call writeln(prefs,'CLASS=LhA_Archive NAME=(#?.LhA|?#.Lzh)  OFFSET=2,"-lh?-"  ACTION='LHA)
  141.         call writeln(prefs,'CLASS=Default ACTION='DEF)
  142.         call writeln(prefs,'0a'x||'#END')
  143.         call close(prefs)
  144.         end
  145.     return
  146. ;;;
  147. /* ;;; Save prefs */
  148. SavePrefs:
  149.     call UsePrefs()
  150.     address command 'copy >NIL: ENV:'PrefsFile 'ENVARC:'
  151.     return
  152. ;;;
  153. /* ;;; Show about requester */
  154. AboutPrefs:
  155.     request title '"CU Amiga CD preferences"' gadgets '"OK"' string VerStr'\nCreated using MUIRexx 3.0'
  156.     return
  157. ;;;
  158.  
  159.